#需要先执行cofig_maix_dock.py
import utime
from Maix import GPIO
from board import board_info
from fpioa_manager import fm
led_b = GPIO(GPIO.GPIO0,GPIO.OUT)
led_b.value(1)

def init_key_boot():#注册
    fm.register(board_info.LED_R,fm.fpioa.GPIO0)
    fm.register(board_info.BOOT_KEY, fm.fpioa.GPIOHS1)
    key = GPIO(GPIO.GPIOHS1, GPIO.IN)
    return key

def deregistration_key_boot():#取消注册
    led_b.value(1)
    fm.unregister(board_info.LED_R)
    fm.unregister(board_info.BOOT_KEY)


while True:
    key_boot=init_key_boot()
    utime.sleep_ms(100)
    if key_boot.value() == 0: # 等待按键按下
        led_b.value(0)
        utime.sleep_ms(1000)
        deregistration_key_boot()
        break



